const { db, query } = require("../../db/db");
const util = require("util");

async function GetAuthorList(req, res) {
  let PageSize = req.body.PageSize;
  let PageNum = req.body.PageNum;

  if (!PageSize) {
    PageSize = 10;
  }
  if (!PageNum) {
    PageNum = 1;
  }

  const select_GetAuthorList_list_sql = util.format(
    "Select \
    UserId, \
    PhoneNumber,\
    Follow,\
    Fans,\
    IFNULL(UserName,'') as UserName, \
    IFNULL(HeaderImg,'') as HeaderImg, \
    IFNULL(SelfDescription,'') as SelfDescription \
    From User\
    Limit %s,%s",
    (PageNum - 1) * PageSize,
    PageSize
  );

  const select_GetAuthorList_list_res = await query(
    select_GetAuthorList_list_sql
  );
  res.send({
    status: 0,
    AuthorList: select_GetAuthorList_list_res,
  });
}

module.exports = { GetAuthorList };
